package com.example.cloud.controller.finance;

import com.example.cloud.controller.common.BaseController;
import com.example.cloud.model.dto.QueryModel;
import com.example.cloud.model.dto.Result;
import com.example.cloud.model.finance.PaymentDetails;
import com.example.cloud.service.finance.PaymentDetailsService;
import com.example.cloud.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by wangtao on 2018/7/31.
 */
@RestController
@RequestMapping("/payment/details")
public class PaymentDetailsController extends BaseController {

    @Autowired
    private PaymentDetailsService paymentDetailsService;

    @PostMapping("/search")
    public Result search(@RequestBody QueryModel model) {
        return this.singleQuery(model, PaymentDetails.class);
    }

    @GetMapping("/find/{recordId}/{type}")
    public Result find(@PathVariable Long recordId, @PathVariable int type){
        return ResultUtil.success(paymentDetailsService.findByRecordId(recordId, type));
    }
}
